﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
// Để sử dụng List<> thì using thư viên này
using System.Collections.Generic;
using DTO;

namespace DAL
{
	/// <summary>
	/// Summary description for LopData.
	/// </summary>
	public class LopDataAccess
	{
		public DataProvider _provider = new DataProvider();
		
		public LopDataAccess()
		{
			_provider.connect();
		}

        
        public List<Lop_DTO> DS_Lop()
		{
			
            SqlDataReader reader= (SqlDataReader)_provider.executeQuery("DS_Lop");
            
            List<Lop_DTO> List_Lop = new List<Lop_DTO>();
            
            while (reader.Read())
            {
                Lop_DTO  lop = new Lop_DTO();
                lop.Malop= reader["Malop"].ToString();
                lop.MaDV = reader["MaDV"].ToString();
                lop.Tenlop = reader["Tenlop"].ToString();
                lop.Siso = int.Parse(reader["Siso"].ToString());
                
                List_Lop.Add(lop);
            }

            reader.Close();
            return List_Lop;
		}
        public List<Lop_DTO> DS_LopThuong()
        {

            SqlDataReader reader = (SqlDataReader)_provider.executeQuery("DS_LopThuong");

            List<Lop_DTO> List_Lop = new List<Lop_DTO>();

            while (reader.Read())
            {
                Lop_DTO lop = new Lop_DTO();
                lop.Malop = reader["Malop"].ToString();
                lop.MaDV = reader["MaDV"].ToString();
                lop.Tenlop = reader["Tenlop"].ToString();
                lop.Siso = int.Parse(reader["Siso"].ToString());

                List_Lop.Add(lop);
            }

            reader.Close();
            return List_Lop;
        }



     
	}
}
